<template>
  <div class="CampusBinhai.vue">
    <h1>这里是滨海校区</h1>
    <div class="search-box">
      <input type="text" v-model="studentId"/>
      <button @click="searchStudent">搜索</button>
    </div>

    <!-- 学生信息展示 -->
    <div v-if="studentInfo">
      <p><strong>学生信息</strong></p>
      <p>学号: {{ studentInfo.id }}</p>
      <p>姓名: {{ studentInfo.name }}</p>
      <p>年龄: {{ studentInfo.age }}</p>
      <p>专业: {{ studentInfo.major }}</p>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        studentId: null,
        studentInfo: null
      };
    },
    methods: {
      searchStudent() {
        // 模拟学生数据查询
        const students = [
          { id: '24219141132', name: '蒋璐瑶', age: 18, major: '计算机科学与技术' }
        ];
        this.studentInfo = students.find(student => student.id === this.studentId) || null;
      }
    },
    mounted() {
      // 初始化时进行一次搜索
      this.searchStudent();
    }
  };
</script>

<style scoped>
  .campus-binhai {
    text-align: center;
    padding: 20px;
  }

  nav {
    margin-bottom: 20px;
  }

  nav .active {
    color: green;
  }

  .search-box {
    margin: 20px 0;
  }

  .search-box input {
    padding: 5px;
    width: 200px;
  }

  .search-box button {
    padding: 5px 10px;
    margin-left: 10px;
  }
    #app {
    font-family: Avenir, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
    color: #2c3e50;
    }

    nav {
    padding: 30px;
    }

    nav a {
    font-weight: bold;
    color: #2c3e50;
    }

    nav a.router-link-exact-active {
    color: #42b983;
    }
</style>
